from selenium import webdriver

class BasePage():

    _base_url = ""

    def __init__(self,base_driver = None):
        """
        浏览器复用
        :return:
        """
        if base_driver is None:
            #通过remote复用浏览器
            chrome_arg = webdriver.ChromeOptions()
            #加入调试地址
            chrome_arg.debugger_address = '127.0.0.1:9222'
            #实例化driver对象
            self.driver = webdriver.Chrome(options=chrome_arg)
            #打开首页
            self.driver.get(self._base_url)
            #添加隐式等待
            self.driver.implicitly_wait(10)
        else:
            self.driver: webdriver = base_driver